package com.kaili.basic.service.impl;

/**
 * Created by xxx on 2019-03-07.
 */

import com.baomidou.mybatisplus.plugins.Page;
import com.kaili.basic.mapper.SupplierMapper;
import com.kaili.basic.pojo.dto.BaseProductQueryDto;
import com.kaili.basic.pojo.dto.SupplierQueryDto;
import com.kaili.basic.pojo.entity.*;
import com.kaili.basic.service.SupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * @author xxx
 * @Copyright: Copyright (c) 2017
 * @Company: 杭州凯立通信有限公司
 */
@Service
@Transactional
public class SupplierServiceImpl implements SupplierService {
    @Autowired
    SupplierMapper supplierMapper;

    @Override
    public int addSupplier(Supplier supplier) {
        supplierMapper.addSupplier(supplier);
        return 1;
    }

    @Override
    public int deleteSuppliers(Map<String,Object> map) {
        supplierMapper.deleteSuppliers(map);
        return 1;
    }

    @Override
    public int updateSupplier(Supplier supplier) {
        supplierMapper.updateSupplier(supplier);
        return 1;
    }

    @Override
    public Page<Supplier> querySupplier(Page<Supplier> page,Supplier supplier) {
        List<Supplier> suppliers = supplierMapper.querySupplier(page,supplier);
        return page.setRecords(suppliers);
    }

    @Override
    public List<SupplierSortUnit> dimQuerySupplier(String parameterName) {
        return supplierMapper.dimQuerySupplier(parameterName);
    }

    @Override
    public SupplierSortUnit querySupplierSortUnit(Long supplierId) {
        return supplierMapper.querySupplierSortUnit(supplierId);
    }

    @Override
    public Page<SupplierProduct> querySupplierProduct(Page<SupplierProduct> page, BaseProductQueryDto queryDto) {
        List<SupplierProduct> supplierProducts = supplierMapper.querySupplierProduct(page,queryDto);
        return page.setRecords(supplierProducts);
    }

    @Override
    public List<SupplierAllQuery> queryAllSupplier() {
        return supplierMapper.queryAllSupplier();
    }

    @Override
    public Long getMaxSupplierId() {
        return supplierMapper.getMaxSupplierId();
    }

    @Override
    public List<SupplierExport> querySupplierExport(SupplierQueryDto supplierQueryDto) {
        return supplierMapper.querySupplierExport(supplierQueryDto);
    }
}
